from django.db import models
from django.db.models import signals
from django.contrib.auth.models import User

class MySiteProfile(models.Model):
    # This is the only required field
    user = models.ForeignKey(User, unique=True)
    
def create_userprofile(sender, **kwargs):
    created = kwargs['created'] # object created or just saved?
    if created:
        MySiteProfile.objects.create(user=kwargs['instance'])  # instance is the user
            # create a BBB "profile" for your user upon creation.
            # now every time a user is created, a BBB profile will exist too.
            # user.BBB or user.get_profile() will always return something

signals.post_save.connect(create_userprofile, sender=User)

    # The rest is completely up to you...
    

class Media(models.Model):
    profile = models.ForeignKey(MySiteProfile)
    file = models.FileField(upload_to='media')
    name = models.CharField(max_length=255)
    #if this file is allowed to be shown publically
    isActive = models.BooleanField(True)
    
class Vote(models.Model):
    file = models.ForeignKey(Media)
    value = models.IntegerField()
    count = models.IntegerField()